﻿/*!
 * Slide menu js
 * Copyright 2011-2015 Akcs, Inc.
 * Licensed ...
 */
 
$(document).ready(function(e) {
   // $("#leftMenuPage")
	//var indexframeWidth=$("#indexPage").width();
	//console.log("indexframeWidth==="+indexframeWidth);
	var indexWidth=$("#indexPage").width();
	console.log("indexWidth=="+indexWidth);
	var leftmenuLeft=$("#leftmenu").offset().left;
	console.log("leftmenuLeft=="+leftmenuLeft);
	var indexMovedLeft=leftmenuLeft;
	var indexWidthDouble=indexWidth*1;
	
	//console.log("indexWidth==="+indexWidth);
	
	$("#RowPageMenu").animate({width:indexWidthDouble});
	$("#leftMenuPage").animate({width:indexMovedLeft});
	$("#indexPage").animate({width:indexWidth});
	
	function initPos(){
		//$("#leftMenuPage").animate({left:(indexMovedLeft-indexWidth)});
		$("#leftMenuPage").animate({left:(-indexMovedLeft)},"normal",function(){
        	//alert("动画完成了")
			$("#leftMenuPage").hide();
    	});
		$("#indexPage").animate({left:0});
	};
	
	function slidePos(){
		//$("#leftMenuPage").animate({left:(indexMovedLeft-indexWidth)});
		$("#leftMenuPage").show().animate({left:0},"normal");
		//$("#indexPage").animate({left:indexMovedLeft});
	};
	
	initPos();

	$("#RowPageMenu").on("swipeleft",function(){
		//console.log("You swiped left!");
	  initPos();
	});
	$("#RowPageMenu").on("swiperight",function(){
		//console.log("You swiped right!");
	  slidePos();
	});

	var leftmenuClicked=0;
	$("#leftmenu").click(function() {
		if(leftmenuClicked % 2==1){
			initPos();
		}else{
			slidePos();
		}
		leftmenuClicked++;
	});

});


